package com.innoking.docsys;

import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

@SpringCloudApplication
public class GateServiceApplication {

	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
		return builder.routes()
				.route(r -> r.path("/baidu")
						.uri("http://www.sina.com.cn/")
				)
				.route("websocket_route", r -> r.path("/apitopic1/**")
						.uri("ws://127.0.0.1:6605"))
				.route(r -> r.path("/userapi3/**")
						.filters(f -> f.addResponseHeader("X-AnotherHeader", "testapi3"))
						.uri("lb://user-service/")
				)
				.build();
	}

	public static void main(String[] args) {
		SpringApplication.run(GateServiceApplication.class, args);
	}

}
